package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.elder.business.domain.ElderlyApartmentFeesDTO;
import com.elder.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.business.domain.ElderlyApartmentFees;
import com.elder.business.service.IElderlyApartmentFeesService;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 收费信息Controller
 * 
 * @author elder
 * @date 2023-11-26
 */
@RestController
@RequestMapping("/business/apartmentFees")
public class ElderlyApartmentFeesController extends BaseController
{
    @Autowired
    private IElderlyApartmentFeesService elderlyApartmentFeesService;

    /**
     * 查询收费信息列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(String memberName,Integer pageNum,Integer pageSize)
    {
        return elderlyApartmentFeesService.getElderFeeInfoList(memberName,pageNum,pageSize);
    }

    /**
     * 导出收费信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:apartmentFees:export')")
    @Log(title = "收费信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElderlyApartmentFees elderlyApartmentFees)
    {
        List<ElderlyApartmentFees> list = elderlyApartmentFeesService.selectElderlyApartmentFeesList(elderlyApartmentFees);
        ExcelUtil<ElderlyApartmentFees> util = new ExcelUtil<ElderlyApartmentFees>(ElderlyApartmentFees.class);
        util.exportExcel(response, list, "收费信息数据");
    }

    /**
     * 获取收费信息详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(elderlyApartmentFeesService.selectElderlyApartmentFeesById(id));
    }

    /**
     * 新增收费信息
     */
    @Anonymous
    @Log(title = "收费信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElderlyApartmentFeesDTO elderlyApartmentFees)
    {
        return toAjax(elderlyApartmentFeesService.insertElderlyApartmentFees(elderlyApartmentFees));
    }

    /**
     * 修改收费信息
     */
    @Anonymous
    @Log(title = "收费信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElderlyApartmentFeesDTO elderlyApartmentFees)
    {
        return toAjax(elderlyApartmentFeesService.updateElderlyApartmentFees(elderlyApartmentFees));
    }

    /**
     * 删除收费信息
     */
    @Anonymous
    @Log(title = "收费信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(elderlyApartmentFeesService.deleteElderlyApartmentFeesByIds(ids));
    }
}
